#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <omp.h>

int main(int argc, char * argv)
{ 
	double time1;
	double time2;

time1 = omp_get_wtime();
char t[sizeof(long)];
time(t); srand48(t[0] + t[1] + t[2] + t[3] + getpid());

double m = 0;
double n = 0;
double step = .000001;
int i = 0;
double z = 0;
int count = (int)(1.0/step);


double myRand = 0;
double function = 0;
//omp_set_num_threads(omp_get_num_procs());
#pragma omp parallel for  private(z,function) shared(step) reduction(+:m,n)
for(i=0;i<count;i++)
	{
n++;
myRand = drand48();
z=i*step;
function = z*sin(z*z);
if(myRand<=function)
{ m++; 	
//	printf("r %f \n",myRand);
}
 z+=step;
	}
		printf("result %f %f %f \n",m, n, (m/n));

time2 = omp_get_wtime();
		printf("time %lf \n",time2-time1 );
	return 0;
}
